//
//  FWContentVoiceView.m
//  BirdLoveSheep
//
//  Created by wwj on 16/3/28.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "FWContentVoiceView.h"
#import "FWTopicModel.h"
#import <AVFoundation/AVFoundation.h>

@interface FWContentVoiceView ()
@property (strong, nonatomic) AVAudioPlayer *voicePlayer;
@end

@implementation FWContentVoiceView
+ (instancetype)contentVoiceView{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
}

- (void)setModel:(FWTopicModel *)model{
    [super setModel:model];
    self.lengthLabel.text = [NSString stringWithFormat:@"%02d:%02d", model.voicetime / 60, model.voicetime %60];
}
- (IBAction)onClickVoiceBtn:(id)sender {
//    NSURL *url = [NSURL URLWithString:self.model.voiceuri];
//    NSData *data = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url] returningResponse:nil error:nil];
////    AVAudioPlayer *voicePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
//    AVAudioPlayer *voicePlayer = [[AVAudioPlayer alloc] initWithData:data error:nil];
//    [voicePlayer prepareToPlay];
//    voicePlayer.numberOfLoops = 1;
//    [voicePlayer play];
//    self.voicePlayer = voicePlayer;
    
    MyLog(@"%@", self.model.voiceuri);
}

@end
